<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="js/vue.js"></script>
    <script src="js/axios.js"></script>
</head>
<body>
<div id="d">
    <input placeholder="用户名" v-model="name"><br>
    <input placeholder="密码" v-model="pass"><br>
    <button @click="login()">登录</button>
</div>
<script>
    new Vue({
        el:"#d",
        data:{
            name:'',
            pass:''
        },
        methods:{
            login(){
                axios.get('http://localhost/login?name='+this.name+"&pass="+this.pass).then(function (ret) {
                    if(ret.data){
                        localStorage.setItem('mytoken', ret.data);
                        location.href = 'product.html';
                    }else{
                        alert("用户名密码错误")
                    }
                });
            }
        }
    });
</script>
</body>
</html>